<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>


</head>
<body>
<FORM method="GET" action="/degloba/linkedinServlet" >
<input type="submit" value="LogonLinkedin" />

</FORM> 


<div>
      <button id="login">LoginFacebook</button>
      <button id="logout">Logout</button>
      <button id="disconnect">Disconnect</button>
      <button id="publicar">publicar</button>
</div>
    
 	
    <div id="user-info" style="display: none;"></div>

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

    <div id="fb-root"></div>
    <script src="http://connect.facebook.net/en_US/all.js"></script>
    <script>
      // initialize the library with the API key
      FB.init({ apiKey: '02b941f1e14d3ef2cb1feeb297159050' });

      // fetch the status on load
      FB.getLoginStatus(handleSessionResponse);


      $('#publicar').bind('click', function() {
    	  FB.ui(
    			  {
    			    method: 'stream.publish',
    			    attachment: {
    			      name: 'JSSDK',
    			      caption: 'The Facebook JavaScript SDK',
    			      description: (
    			        'A small JavaScript library that allows you to harness ' +
    			        'the power of Facebook, bringing the user\'s identity, ' +
    			        'social graph and distribution power to your site.'
    			      ),
    			      href: 'http://fbrell.com/'
    			    },
    			    action_links: [
    			      { text: 'fbrell', href: 'http://fbrell.com/' }
    			    ]
    			  },
    			  function(response) {
    			    if (response && response.post_id) {
    			      alert('Post was published.');
    			    } else {
    			      alert('Post was not published.');
    			    }
    			  }
    			);

        });

      
      $('#login').bind('click', function() {
        FB.login(handleSessionResponse);
      });

      $('#logout').bind('click', function() {
        FB.logout(handleSessionResponse);
      });

      $('#disconnect').bind('click', function() {
        FB.api({ method: 'Auth.revokeAuthorization' }, function(response) {
          clearDisplay();
        });
      });

      // no user, clear display
      function clearDisplay() {
        $('#user-info').hide('fast');
      }

      // handle a session response from any of the auth related calls
      function handleSessionResponse(response) {
        // if we dont have a session, just hide the user info
        if (!response.session) {
          clearDisplay();
          return;
        }

        // if we have a session, query for the user's profile picture and name
        FB.api(
          {
            method: 'fql.query',
            query: 'SELECT name, pic FROM profile WHERE id=' + FB.getSession().uid
          },
          function(response) {
            var user = response[0];
            $('#user-info').html('<img src="' + user.pic + '">' + user.name).show('fast');
          }
        );
      }
    </script>


</body>
</html>